package o;

import android.app.AlertDialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.fastengine.fastview.startFastappEngine.bean.RpkInfo;
import com.huawei.gamebox.service.welfare.gift.bean.GiftCardBean;
import com.huawei.gamebox.service.welfare.gift.card.BaseGiftCard;
import huawei.widget.HwButton;
import java.util.LinkedHashMap;

public class fce extends BaseGiftCard {
    private GiftCardBean ʻ;
    private RelativeLayout ʻॱ;
    private ImageView ʼ;
    private TextView ʽ;
    protected boolean ˊ;
    private View ˊॱ;
    protected TextView ˋ;
    private boolean ˋॱ = false;
    private String ˎ;
    protected boolean ˏ = false;
    private TextView ˏॱ;
    private HwButton ͺ;
    private int ॱˊ;
    private ViewGroup ॱˋ;
    private TextView ॱॱ;
    private evx ॱᐝ = new evx(this) {
        final /* synthetic */ fce ˎ;

        {
            this.ˎ = r1;
        }

        public void ˋ(View view) {
            if (this.ˎ.ʻ.ʼ() == 0) {
                this.ˎ.ʻ();
            } else if (2 == this.ˎ.ʻ.ʼ()) {
                this.ˎ.ॱˊ();
            }
        }
    };
    private ImageView ᐝ;

    class a implements o.ckh.a {
        final /* synthetic */ fce ˏ;

        private a(fce o_fce) {
            this.ˏ = o_fce;
        }

        public void ˏ(AlertDialog alertDialog, com.huawei.appgallery.foundation.ui.framework.widget.dialog.dialogactivity.DialogActivity.a aVar, int i) {
            if (alertDialog == null) {
                return;
            }
            if (-2 == i) {
                alertDialog.dismiss();
            } else if (-1 == i) {
                fcl.ˋ(this.ˏ.ॱ, this.ˏ.ʻ.ˊˊ(), this.ˏ.ʻ.ـॱ());
            }
        }
    }

    class d implements AccountBussinessListener {
        final /* synthetic */ fce ˏ;

        private d(fce o_fce) {
            this.ˏ = o_fce;
        }

        public void onAccountBusinessResult(ccp o_ccp) {
            eoj.ˋ().ˊ(this.ˏ.ˎ);
        }
    }

    private void ʻ() {
        if (!UserSession.getInstance().isLoginSuccessful()) {
            eoj.ˋ().ˎ(this.ˎ, new d());
            ˎ(11);
            if (fcl.ˊ(this.ॱˊ)) {
                ezl.ˎ().ˏ();
            } else {
                eod.ॱ(this.ॱ);
            }
        } else if (fcl.ˏ(this.ॱ, this.ʻ.ͺˏ(), this.ʻ.ॱـ(), this.ʻ.ˊᐝ())) {
            ʻॱ();
            ˎ(4);
        } else {
            ˎ(10);
            ॱˎ();
        }
    }

    private void ॱˊ() {
        if (!ˏ(this.ʻ.ॱᐝ())) {
            ˎ(0);
            fcl.ˋ(this.ʻ.ͺ(), this.ॱ);
            fcl.ˎ(exp$f.ʾ);
        } else if (!fcl.ˏ(this.ॱ, this.ʻ.ͺˏ(), this.ʻ.ॱـ(), this.ʻ.ˊᐝ())) {
            ˎ(10);
            ॱˎ();
        } else if (fcl.ˊ(this.ॱˊ)) {
            ˎ(0);
            fcl.ˎ(exp$f.ـ);
        } else {
            ˎ(12);
            fcl.ॱ(this.ॱ, this.ʻ);
        }
    }

    public fce(Context context, boolean z, int i) {
        super(context);
        this.ॱ = context;
        this.ॱˊ = i;
        this.ˎ = "VerticalGiftCard" + System.currentTimeMillis();
        this.ˊ = z;
    }

    public void ॱ(boolean z) {
        this.ˏ = z;
    }

    public cgz ˏ(View view) {
        view.setBackgroundResource(exp$e.ᐝ);
        this.ᐝ = (ImageView) view.findViewById(o.exp.d.ॱͺ);
        this.ʽ = (TextView) view.findViewById(o.exp.d.ᐧ);
        this.ˋ = (TextView) view.findViewById(o.exp.d.ॱʼ);
        this.ॱॱ = (TextView) view.findViewById(o.exp.d.ᐝˋ);
        this.ˏॱ = (TextView) view.findViewById(o.exp.d.ᐝᐝ);
        this.ͺ = (HwButton) view.findViewById(o.exp.d.ॱʻ);
        this.ʼ = (ImageView) view.findViewById(o.exp.d.ʻˊ);
        this.ˊॱ = view.findViewById(o.exp.d.ˋˋ);
        this.ʻॱ = (RelativeLayout) view.findViewById(o.exp.d.ॱـ);
        this.ॱˋ = (ViewGroup) view.findViewById(o.exp.d.ᐨ);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof GiftCardBean) {
            GiftCardBean giftCardBean = (GiftCardBean) cardBean;
            this.ʻ = giftCardBean;
            eqx.ˏ(this.ᐝ, this.ʻ.ॱˌ(), "app_default_icon");
            this.ʽ.setText(this.ʻ.ˊ());
            if (TextUtils.isEmpty(this.ʻ.ॱ())) {
                this.ˋ.setVisibility(8);
            } else {
                this.ˋ.setVisibility(0);
                this.ˋ.setText(this.ʻ.ॱ());
            }
            if (-1 == this.ʻ.ॱˊ()) {
                this.ॱॱ.setText(this.ॱ.getString(exp$f.ʻˊ, new Object[]{ॱ(99999)}));
            } else {
                this.ॱॱ.setText(this.ॱ.getString(exp$f.ʻˊ, new Object[]{ॱ(this.ʻ.ॱˊ())}));
            }
            ˋॱ();
            ˊ(this.ʻ.ʼ(), this.ʻ.ॱᐝ());
            ˋ(this.ʻ.ˋॱ());
            this.ͺ.setOnClickListener(this.ॱᐝ);
            ˏॱ();
            if (!dof.ॱ(this.ʻ.ͺ())) {
                Object ͺ = giftCardBean.ͺ();
                if (!TextUtils.isEmpty(ͺ)) {
                    giftCardBean.ˏ(ͺ);
                }
            }
            ˊ();
            if (this.ʻ.ʿ() == 1) {
                fco.ˋ(null);
            }
        }
    }

    private void ˏॱ() {
        int i = 4;
        int i2 = 0;
        if (this.ˊॱ == null) {
            return;
        }
        if (this.ˏ) {
            View view = this.ˊॱ;
            if (!this.ˊ) {
                i = 0;
            }
            view.setVisibility(i);
            return;
        }
        view = this.ˊॱ;
        if (!ˊᐝ()) {
            i2 = 4;
        }
        view.setVisibility(i2);
    }

    protected void ˊ() {
        if (this.ʻॱ == null) {
            return;
        }
        if (this.ˋॱ && ˎ()) {
            LayoutParams layoutParams = (LayoutParams) this.ʻॱ.getLayoutParams();
            layoutParams.setMargins(0, 0, 0, this.ॱ.getResources().getDimensionPixelSize(exp$a.ʽॱ));
            layoutParams.removeRule(13);
            this.ʻॱ.setLayoutParams(layoutParams);
            ˊॱ();
            return;
        }
        layoutParams = (LayoutParams) this.ʻॱ.getLayoutParams();
        layoutParams.setMargins(0, this.ॱ.getResources().getDimensionPixelSize(exp$a.ʽॱ), 0, this.ॱ.getResources().getDimensionPixelSize(exp$a.ʽॱ));
        layoutParams.addRule(13);
        this.ʻॱ.setLayoutParams(layoutParams);
        this.ˊˋ.setMinimumHeight(this.ॱ.getResources().getDimensionPixelSize(exp$a.ˋᐝ));
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void ˊॱ() {
        /*
        r4 = this;
        r2 = 0;
        r0 = r4.ॱ;
        r0 = r0.getResources();
        r1 = o.exp$a.ˋᐝ;
        r1 = r0.getDimensionPixelSize(r1);
        r0 = r4.ॱˋ;
        if (r0 == 0) goto L_0x0051;
    L_0x0011:
        r0 = r4.ॱˋ;
        r0.measure(r2, r2);
        r0 = r4.ॱˋ;
        r0 = r0.getMeasuredHeight();
        r2 = r4.ॱ;
        r2 = r2.getResources();
        r3 = o.exp$a.ˋᐝ;
        r2 = r2.getDimensionPixelSize(r3);
        r0 = r2 - r0;
        r2 = r4.ॱ;
        r2 = r2.getResources();
        r3 = o.exp$a.ˉ;
        r2 = r2.getDimensionPixelSize(r3);
        r0 = r0 - r2;
        r0 = r0 / 2;
        if (r0 < 0) goto L_0x0051;
    L_0x003b:
        r2 = r4.ॱ;
        r2 = r2.getResources();
        r3 = o.exp$a.ˋˋ;
        r2 = r2.getDimensionPixelSize(r3);
        r0 = r2 - r0;
        if (r0 < 0) goto L_0x0051;
    L_0x004b:
        r1 = r4.ˊˋ;
        r1.setMinimumHeight(r0);
        return;
    L_0x0051:
        r0 = r1;
        goto L_0x004b;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.fce.ˊॱ():void");
    }

    private void ˋॱ() {
        if (this.ʻ.ʾ() == 1) {
            ͺ();
            return;
        }
        if (1 < this.ʻ.ॱˎ()) {
            this.ˏॱ.setVisibility(0);
            String string = this.ॱ.getString(exp$f.ॱʻ, new Object[]{Integer.valueOf(r0)});
            this.ˏॱ.setText(this.ॱ.getString(exp$f.ॱʽ, new Object[]{string}));
            return;
        }
        this.ˏॱ.setVisibility(8);
    }

    private void ͺ() {
        if (this.ʻ.ˈ()) {
            this.ˏॱ.setVisibility(0);
            if (this.ʻ.ʽॱ() == this.ʻ.ʼॱ()) {
                this.ˏॱ.setText(this.ॱ.getString(exp$f.ˋᐝ, new Object[]{Integer.valueOf(this.ʻ.ʽॱ())}));
                return;
            }
            this.ˏॱ.setText(this.ॱ.getString(exp$f.ˍ, new Object[]{Integer.valueOf(this.ʻ.ʽॱ()), Integer.valueOf(this.ʻ.ʼॱ())}));
            return;
        }
        this.ˏॱ.setVisibility(8);
    }

    private void ˋ(int i) {
        if (this.ʼ == null) {
            return;
        }
        if (i == 1) {
            this.ʼ.setVisibility(0);
        } else {
            this.ʼ.setVisibility(4);
        }
    }

    private void ˊ(int i, int i2) {
        switch (i) {
            case 0:
                ˎ(exp$f.ˈ, true);
                return;
            case 1:
                ˎ(exp$f.ﾟ, false);
                return;
            case 2:
                if (ˏ(i2)) {
                    ˎ(exp$f.ʹ, true);
                    return;
                } else {
                    ˎ(exp$f.ʽॱ, true);
                    return;
                }
            case 3:
                ˎ(exp$f.ˑ, false);
                return;
            case 4:
                ˎ(exp$f.ˋˋ, false);
                return;
            default:
                return;
        }
    }

    private boolean ˏ(int i) {
        return 8 == i || 9 == i;
    }

    private void ˎ(int i, boolean z) {
        if (this.ͺ != null) {
            this.ͺ.setText(i);
            this.ͺ.setAlpha(1.0f);
            this.ͺ.setEnabled(z);
        }
    }

    private void ˎ(int i) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put(RpkInfo.APPID, this.ʻ.ͺˏ());
        linkedHashMap.put("type", String.valueOf(i));
        linkedHashMap.put("service_type", String.valueOf(this.ॱˊ));
        linkedHashMap.put("detailid", this.ʻ.ॱॱ());
        dgh.ˋ("card_installbtn_click", linkedHashMap);
    }

    private void ॱˎ() {
        fcd o_fci = new fci();
        o_fci.ˋ("VerticalGiftCard");
        o_fci.ˏ(fcl.ॱ(exp$f.ˌ));
        o_fci.ॱ(fcl.ॱ(exp$f.ॱˎ));
        o_fci.ˎ(new a());
        o_fci.ˎ(fcl.ॱ(exp$f.ˏˎ));
        o_fci.ॱ(this.ॱ);
        fcl.ˊ(this.ॱ, o_fci, this.ॱˊ);
    }

    private void ʻॱ() {
        new fbx(this.ॱ, this.ʻ, this.ॱˊ).ˏ();
    }

    public void ˎ(boolean z) {
        this.ˋॱ = z;
    }
}
